/* 布尔值 */
// let isDone: boolean = false;

/* 数字 */
// let decLiteral: number = 6;
// let hexLiteral: number = 0xf00d;
// let binaryLiteral: number = 0b1010;
// console.log(decLiteral);


/* 字符串 */
// let mname: string = "bob";
// mname = "smith";


/* 数组 */
// let list1: number[] = [1, 2, 3];
// let list2: Array<number> = [1, 2, 3];

/* 元组 Tuple */
// let x: [string, number];
// x = ['age', 10]; // OK
// // x = [10, 'hello']; // Error
// console.log(x[0].substring(1)); // OK
// // console.log(x[1].substring(1)); // Error, 'number' does not have 'substr'

/* 枚举 */
// enum Color {Red, Green, Blue}
// let c: Color = Color.Red;
// console.log(c);//0
// c= Color.Green;
// console.log(c);
// c = Color.Blue;
// console.log(c);

// enum Color {Red = 100, Green, Blue}
// let c: Color = Color.Green;
// console.log(c);

// enum Color {Red = 1, Green = 2, Blue = 4}
// let c: Color = Color.Blue;
// console.log(c);

// enum Color {Red = 1, Green, Blue}
// let colorName: string = Color[2];
// console.log(colorName);  // 显示'Green'因为上面代码里它的值是2
// console.log(Color);


/* any */
// let notSure:any = 4;
// notSure = "maybe a string instead";
// notSure = false; // okay, definitely a boolean

// let notSure: any = 4;
// notSure.ifItExists(); // okay, ifItExists might exist at runtime
// notSure.toFixed(); // okay, toFixed exists (but the compiler doesn't check)
// let prettySure: Object = {value:123.456789};
// console.log(123.456789.toFixed(2));
// prettySure.toFixed(); // Error: Property 'toFixed' doesn't exist on type 'Object'.

// let list: any[] = [1, true, "free"];
// list[1] = 100;

/* 空值 void 函数的返回值类型定义专用（代表无返回值）*/
// function warnUser(): void {
//     alert("This is my warning message");
// }
// // void类型可以被null和undefined赋值
// let unusable: void = undefined;
// unusable = null
// unusable = 123

/* Null 和 Undefined */
// let u: undefined = undefined;
// let n: null = null;
// let str:string = undefined//strictNullChecks开启时不合法

/* Never */
// 返回never的函数必须存在无法达到的终点
// function error(message: string): never {
//     throw new Error(message);
//     console.log("函数执行到此处可以免费领取30K的offer一个");
// }

// // 推断的返回值类型为never
// function fail() {
//     const ret =  error("Something failed");
//     return ret
// }

// 返回never的函数必须存在无法达到的终点
// function infiniteLoop(): never {
//     while (true) {
//     }
//     console.log("函数执行到此处可以免费领取30K的offer一个");
// }

/* 类型断言 */
// let someValue: any = "this is a string";
// let strLength: number = (<string>someValue).length;

// let someValue: any = "this is a string";
// let strLength: number = (someValue as string).length;

